package com.amt.olcacon;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public class FileDownloader {
    public static void downloadFile(String fileUrl, String savePath) throws IOException {
        URL url = new URL(fileUrl);
        try (InputStream in = url.openStream()) {
            Files.copy(in, Paths.get(savePath), StandardCopyOption.REPLACE_EXISTING);
        }
    }
    
    // 使用示例
    public static void main(String[] args) {
        String fileUrl = "https://dev-productcarbon-amtcarbon.app.codewave.163.com:443/upload/工序导入模板v2.0(1).xlsx?fileName=工序导入模板v2.0(1).xlsx&fut=1757387586758&ai=5cee4b16-a895-4d29-a002-c2845cf526ec&con=lcap_default_connection&fpp=/official_website";
        try {
            downloadFile(fileUrl, "local_file.xlsx");
            System.out.println("文件下载成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}